<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <div>
            <p id="p" ref='p'>我是p标签</p>
            <h1 id="h" ref='h'>我是h1标签</h1>

            <hellowolrd ref='hello'></hellowolrd>
        </div>
    </div>


    <script>

        Vue.component('hellowolrd',{
            data(){
                return {
                    name:'hellowolrd22222'
                }
            },
            methods:{
                fn1(){
                    alert('fn1')
                }
            },
            template:`<div>helloworld外部组件</div>`
        })



   
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue22222!'
            },
            mounted() {
                var p = document.getElementById('p')
                console.log('p',p)
                // ref第一个功能如果在普通的 DOM 元素上使用 ref 属性，则引用指向的就是 DOM 元素

                console.log('this.$refs.p',this.$refs.p)
                this.$refs.p.innerHTML='我是新的p表亲内容'

                // ref第二个功能 与真实组件配合  
                 console.log(   this.$refs.hello.name)
                 this.$refs.hello.fn1()
            }
        })

        console.log(app)

   

    </script>
</body>

</html>